
(in-package :oali.proto)

;;
;; errors
;;

(define-condition parser-error (error)
  ((reason ; reason why the error occurs
    :initarg :reason
    :initform nil
    :reader reason)
   (entity ; entity that is a subject of error (argument, variable, etc.)
    :initarg :entity
    :initform nil
    :reader entity)
   (where ; location where an error occurs in the source form
    :initarg :where
    :initform nil
    :reader where)))


(defmethod print-object ((obj parser-error) stream)
   (print-unreadable-object (obj stream :type t :identity t)
     (format stream "reason: ~a entity: ~a where: ~a"
	     (reason obj) (entity obj) (where obj))))


;; internal error cause shall come in the entity slot
(define-condition internal-error (parser-error) ())

;; indicates error when certain parameter is omitted
(define-condition ctor-error (internal-error) ())

;; facility, that is not implemented shall come in the entity slot
(define-condition not-implemented (internal-error) ())



;; represents syntax error
(define-condition syntax-error (parser-error) ())


;; represents semantic error that regards to the correct syntax form
(define-condition semantic-error (parser-error) ())

;; indicates duplicate definition of certain entity
(define-condition duplicate-definition (semantic-error) ())

;; indicates entity that is not known here
(define-condition not-found (semantic-error) ())
